#define baseAddress24AA512 0xA0

void writeByte24AA512(int8 deviceAddress, int16 memAddress, int8 data);
int8 readByte24AA512(int8 deviceAddress, int16 memAddress);

void writeByte24AA512(int8 deviceAddress, int16 memAddress, int8 data)
{
   i2c_start();
   i2c_write(baseAddress24AA512 + (deviceAddress<<1));
   i2c_write(memAddress>>8);
   i2c_write(memAddress);
   i2c_write(data);
   i2c_stop();
   delay_ms(5);
}

int8 readByte24AA512(int8 deviceAddress, int16 memAddress)
{
   int8 returnByte=0;
   
   i2c_start();
   i2c_write(baseAddress24AA512 + (deviceAddress<<1));
   i2c_write(memAddress>>8);
   i2c_write(memAddress);
   i2c_start();
   i2c_write((baseAddress24AA512 + (deviceAddress<<1))|1);
   returnByte = i2c_read(0);
   i2c_stop();
   return returnByte;
}
